<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('增加/项目操作方式')"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <form class="form-horizontal m" id="form-horizontal m">
        <input name="classPlanDetailId" id="classPlanDetailId" th:value="${classPlanDetailId}" type="hidden"/>
        <input name="linkRuleType" id="linkRuleType" th:value="${linkRuleType}" type="hidden"/>
        <div id="menuTrees" class="ztree ztree-border"></div>
    </form>
    <!--    <div class="row">-->
    <!--        <div class="btn-group-sm" id="toolbar" role="group">-->
    <!--            <a class="btn btn-success" onclick="$.operate.add()">-->
    <!--                <i class="fa fa-plus"></i> 新增训练计划表-->
    <!--            </a>-->
    <!--            <a class="btn btn-primary single disabled" onclick="$.operate.edit()">-->
    <!--                <i class="fa fa-edit"></i> 训练包配置-->
    <!--            </a>-->

    <!--        </div>-->
    <!--        <div class="col-sm-12 select-table table-striped">-->
    <!--            <table id="bootstrap-table"></table>-->
    <!--        </div>-->
    <!--    </div>-->
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: ztree-js"/>
<script th:inline="javascript">
    // 权限

    // 字典
    var prefix = ctx + "business/classPlanDetail";
    $(function () {
        var url = prefix + "/getProjectTree?classPlanDetailId=" + $("#classPlanDetailId").val()+"&linkRuleType="+$("#linkRuleType").val();
        var options = {
            id: "menuTrees",
            url: url,
            check: {enable: true, chkboxType: {"Y": "", "N": ""}},
            expandLevel: 0
        };
        $.tree.init(options);
    });

    function edit() {
        var classPlanDetailId = $("#classPlanDetailId").val();
        var menuIds = $.tree.getCheckedNodes();
        var linkRuleType = $("#linkRuleType").val();
        var reqData = {
            "classPlanDetailId": classPlanDetailId,
            "integrationIds": menuIds,
            "linkRuleType":linkRuleType,
            "trainPackageId":menuIds
        };
        $.ajax({
            type: "POST",
            url: prefix + "/saveProject",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: JSON.stringify(reqData),
            error: function (request) {
                $.modal.alertError("系统错误");
            },
            success: function (data) {
                $.operate.successCallback(data);
            }
        });
    }

    function submitHandler() {
        edit();
    }


</script>
</body>

</html>